//
//  Person.m
//  字典嵌套字典使用KVC解析
//
//  Created by 周成龙 on 2018/3/12.
//  Copyright © 2018年 XZL. All rights reserved.
//

#import "Person.h"

@implementation Person

- (instancetype)initModelWithDictionary:(NSDictionary *)dict {
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
        Car *car = [Car modelWithDictionary:dict[@"car"]];
        self.car = car;
    }
    return self;
}

+ (instancetype)modelWithDictionary:(NSDictionary *)dict {
    return [[self alloc] initModelWithDictionary:dict];
}

//- (void)setCar:(Car *)car {
//    _car = car;
//    car = [Car modelWithDictionary:self.car];
//}

- (NSString *)description {
    return [NSString stringWithFormat:@"人名：%@ 车名：%@", _name, _car.name];
//    return [NSString stringWithFormat:@"人名：%@", _name];
}

@end
